﻿using System;
using Shell.Common;

namespace Shell.KnowledgeBase
{
    public class Atom : Term
    {
        public Atom(string value)
        {
            value.NotNull();
            Value = value;
        }

        public string Value { get; private set; }

        public override string ToString()
        {
            return Value.Length == 1
                       ? Value
                       : "#" + Value;
        }

        public override bool Equals(object obj)
        {
            if (obj is Atom)
            {
                return string.Equals(Value, ((Atom) obj).Value, StringComparison.CurrentCultureIgnoreCase);
            }

            return false;
        }

        public override int GetHashCode()
        {
            return Value.GetHashCode();
        }
    }
}